{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "89a4cdb8",
   "metadata": {},
   "outputs": [],
   "source": [
    "import cv2\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline\n",
    "\n",
    "def rgb_to_hsv(r, g, b):\n",
    "    \"\"\"Convert RGB to HSV\"\"\"\n",
    "    rgb_array = np.uint8([[[b, g, r]]])\n",
    "    hsv_cv = cv2.cvtColor(rgb_array, cv2.COLOR_BGR2HSV)[0][0]\n",
    "    h_std = hsv_cv[0] * 2.0\n",
    "    s_std = hsv_cv[1] / 2.55\n",
    "    v_std = hsv_cv[2] / 2.55\n",
    "    return {\n",
    "        'rgb': (r, g, b),\n",
    "        'hsv_cv': hsv_cv,\n",
    "        'hsv_std': (h_std, s_std, v_std)\n",
    "    }\n",
    "\n",
    "def show_color_info(r, g, b):\n",
    "    \"\"\"Display color info compactly\"\"\"\n",
    "    colors = rgb_to_hsv(r, g, b)\n",
    "    hcv, scv, vcv = colors['hsv_cv']\n",
    "    hstd, sstd, vstd = colors['hsv_std']\n",
    "    \n",
    "    # Create compact RGB and HSV images\n",
    "    rgb_image = np.full((50, 100, 3), (r, g, b), dtype=np.uint8)\n",
    "    hsv_array = np.uint8([[[hcv, scv, vcv]]])\n",
    "    bgr_image = cv2.cvtColor(hsv_array, cv2.COLOR_HSV2BGR)[0][0]\n",
    "    hsv_rgb_image = np.full((50, 100, 3), (bgr_image[2], bgr_image[1], bgr_image[0]), dtype=np.uint8)\n",
    "    \n",
    "    # Create figure with 2 small images side by side\n",
    "    fig, axs = plt.subplots(1, 2, figsize=(8, 2))\n",
    "    \n",
    "    # RGB image\n",
    "    axs[0].imshow(rgb_image)\n",
    "    axs[0].set_title(f'RGB: ({r}, {g}, {b})', fontsize=10)\n",
    "    axs[0].axis('off')\n",
    "    \n",
    "    # HSV image\n",
    "    axs[1].imshow(hsv_rgb_image)\n",
    "    axs[1].set_title(f'HSV: ({hcv}, {scv}, {vcv})', fontsize=10)\n",
    "    axs[1].axis('off')\n",
    "    \n",
    "    plt.tight_layout()\n",
    "    plt.show()\n",
    "    \n",
    "    # Print numerical values only\n",
    "    print(f\"RGB: ({r}, {g}, {b})\")\n",
    "    print(f\"HSV (OpenCV): H={hcv}, S={scv}, V={vcv}\")\n",
    "    print(f\"HSV (Standard): H={hstd:.1f}°, S={sstd:.1f}%, V={vstd:.1f}%\")\n",
    "    print(\"-\" * 40)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7abec78a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAtYAAADECAYAAAC7kWZ/AAAAOnRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjEwLjUsIGh0dHBzOi8vbWF0cGxvdGxpYi5vcmcvWftoOwAAAAlwSFlzAAAPYQAAD2EBqD+naQAAFexJREFUeJzt3X9Q1VX+x/HXBUFABH/BGqDIsquplZKuP7cl/JmZYa3pijuBuJMUrj92/IXZYNOm7a7m2qTuutl1dg1XLbEdQ10yFV3GafNHCiRi/iANx1yVEVEkON8/Gu63KxcEPabW8zHzmZHzOfec972jn/Pqcw+fHMYYIwAAAAC3xOtOFwAAAAB8HxCsAQAAAAsI1gAAAIAFBGsAAADAAoI1AAAAYAHBGgAAALCAYA0AAABYQLAGAAAALCBYAwAAABYQrHFL/ve//yk0NFQnTpy406Xc886dO6fQ0FCdOnXqTpcCAI3y0ksv6bnnnrvTZfwgFBQUKCIiQpcvX77TpcADgvVdLikpSQ6HQw6HQz4+PoqKitLMmTN19erVWn23b9+uJ554QiEhIfLz81N0dLTGjBmjnJwcV58dO3a4xnM4HPL391fXrl21YsWKm6rv1VdfVXx8vDp06CBJ+vTTTzV27Fi1a9dO/v7+6ty5s5YsWeL2mt27d6t///5q3bq1/P39df/992vx4sVufTp06OBWZ82RmpraqPomT56sHj16qGnTpurevbvHPuvWrVP37t0VEBCgyMhI/elPf3I7X1JSoo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Tp09r0KBBDa4P35E7fMccN1DX134LFiwwISEhbl/ZZWdnm2HDhplWrVqZJk2amB/96Edm5MiRZsuWLa4+NV8X1hxNmjQxUVFRZvr06W5jOZ1O05C/Hr169TJ/+ctfXD+np6e7jV9zREZGuvq88cYbpmvXriYgIMAEBQWZmJgYs2zZMrd9f8YYs3Xr1nq/YkxMTLzhV4axsbEe6zl+/LgxxpivvvrK9OnTxzRr1swEBASYgQMHetxbfaP3VPO51ox7vZotOZ6O7du3u/plZGSYTp061fueAPxwNXQryLvvvmsef/xxc9999xlfX18TFhZmfvnLX5qDBw/Weu0XX3xhvLy8TNeuXWudi4yMNOnp6fXWlJWVZcLDw92u4XVd7+rbvy0Pe6xvNH9d1/jExERXnzFjxrg+h/DwcDNmzBi3x+idPn3aDBs2zISGhhofHx8TERFhEhISzOHDh63XkpycbCIjI42vr68JCQkxAwcONP/+979rjZWWlmbatWtXa12sMX/+fDN06NA6a8Gd4zDGmNuS2PGD8MEHH2jGjBnKy8uTl9d3u7MoNjZWcXFx9T4K6rvidDo1f/58FRQUyMfH56bH6dOnjyZPnqyEhASL1QHA7WOMUe/evTVt2jTXXWAbysvL1bp1a23evFmPPvqotXHv9VquXbumn/70p8rIyFD//v3vaC2oja0guCXDhw9XUVGRTp8+fUvP+2ys0tJSff755/rggw++sznrk5WVpfnz599SqD537pyefvppqwsTANxuDodDK1asqPVY11u1fft2DRgw4I4H2butluLiYs2ZM4dQfZfijjUAAABgAU8FAQAAACwgWAMAAAAWEKwBAAAACwjWAAAAgAUEawAAAMCCBj9u7/wO7xt3AoB7XKtHq+50Cfek89tZIwB8/7WKq3+N4I41AAAAYAHBGgAAALCAYA0AAABYQLAGAAAALCBYAwAAABYQrAEAAAALCNYAAACABQRrAAAAwAKCNQAAAGABwRoAAACwgGANAAAAWECwBgAAACwgWAMAAAAWEKwBAAAACwjWAAAAgAUEawAAAMACgjUAAABgAcEaAAAAsIBgDQAAAFhAsAYAAAAsIFgDAAAAFhCsAQAAAAsI1g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AAADAAoI1AAAAYAHBGgAAALCAYA0AAABYQLAGAAAALCBYAwAAABYQrAEAAAALCNYAAACABQRrAAAAwAKCNQAAAGABwRoAAACwgGANAAAAWECwBgAAACxwGGPMnS4CAAAAuNdxxxoAAACwgGANAAAAWECwBgAAACwgWAMAAAAWEKwBAAAACwjWAAAAgAUEawAAAMACgjUAAABgAcEaAAAAsOD/ACktnSV1lMVRAAAAAElFTkSuQmCC",
      "text/plain": [
       "<Figure size 800x200 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "RGB: (237, 191, 2)\n",
      "HSV (OpenCV): H=24, S=253, V=237\n",
      "HSV (Standard): H=48.0°, S=99.2%, V=92.9%\n",
      "----------------------------------------\n"
     ]
    }
   ],
   "source": [
    "# Example usage\n",
    "show_color_info(237, 191, 2)   \n",
    "\n",
    "# 6, 173, 158\n",
    "# 6, 127, 166\n",
    "# 5, 140, 167"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
